<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"> 

    <h:head>
        <title>Registration</title>
    </h:head>
    <h:body> 
        <h:form>
            <p:growl id="growl" showDetail="true" sticky="true"/>
            <p:fieldset legend="Registration Form" widgetVar="regWidget" style="width: 600px; margin: 0 auto;">
                <h:panelGrid columns="3" width="550" border="0" style="margin: 0 auto;">

                    <h:outputLabel value="First Name" />
                    <p:inputText value="#{registrationGUI.ru.name}"
                                 id="firstName"
                                 required="true" 
                                 requiredMessage="FirstName is required"
                                 validatorMessage="FirstName should be of length from 4 to 15 chars"
                                 >
                        <f:validateLength minimum="4" maximum="15" for="firstName"></f:validateLength>
                    </p:inputText>
                    <p:message for="firstName" />

                    <h:outputLabel value="Last Name" />
                    <p:inputText value="#{registrationGUI.ru.surname}"
                                 id="lastName"
                                 required="true" 
                                 requiredMessage="LastName is required"
                                 validatorMessage="LastName should be of length from 5 to 15 chars"
                                 >
                        <f:validateLength minimum="5" maximum="15" for="lastname"></f:validateLength>
                    </p:inputText>
                    <p:message for="lastName" />

                    <h:outputLabel value="Birth Date" />
                    <p:calendar value="#{registrationGUI.ru.birthdate}"
                                id="dob"
                                converterMessage="Invalid Date"
                                pattern="dd-MM-yyyy"
                                maxdate="#{registrationGUI.currentDate}"
                                >
                        <p:ajax event="change" update="dob" listener="#{registrationGUI.validateEventDate()}"/>
                    </p:calendar>
                    <p:message for="dob" />

                    <h:outputLabel value="Address" />
                    <p:inputText value="#{registrationGUI.ru.address}"
                                 id="address"></p:inputText>
                    <p:message for="address" />

                    <h:outputLabel value="Email" />
                    <p:inputText value="#{registrationGUI.ru.email}"
                                 id="email"
                                 required="true"
                                 requiredMessage="Email is required"
                                 validatorMessage="Invalid Email">
                        <f:validateRegex pattern="[a-zA-Z0-9]+@[a-zA-Z]+.[a-zA-Z]{2,3}"></f:validateRegex>   
                    </p:inputText>
                    <p:message for="email" />


                    <h:outputLabel for="password">Password:</h:outputLabel>
                    <p:password id="password" value="#{registrationGUI.ru.password}"
                                required="true"
                                feedback="true" match="pwd2" label="Password"/>
                    <p:message for="password" />

                    <h:outputLabel for="pwd2">Confirm Password:</h:outputLabel>
                    <p:password id="pwd2" label="Confirm Password"/>

                </h:panelGrid>
                <h:panelGrid columns="2" width="550" border="0" style="margin: 0 auto;">

                    <p:outputLabel for="calendar" value="Calendar Type:" />
                    <p:selectOneRadio id="calendar" value="#{registrationGUI.public_bool}">
                        <f:selectItem itemLabel="Private" itemValue="false"/>
                        <f:selectItem itemLabel="Public" itemValue="true"/>
                    </p:selectOneRadio>

                    <p:commandButton value="Register" action="#{registrationGUI.register()}" ajax="false" update="growl"/>
                </h:panelGrid>
            </p:fieldset>

        </h:form>
    </h:body> 
</html>
